Skip to content

Conversation

@DaveGosselin-MariaDB
Copy link
Member

@DaveGosselin-MariaDB DaveGosselin-MariaDB commented Oct 29, 2025

Syntax support for FULL JOIN, FULL OUTER JOIN, NATURAL FULL JOIN, and NATURAL FULL OUTER JOIN in the parser.

While we accept full join syntax, such joins are not yet supported. Queries specifying any of the above joins will fail with ER_NOT_SUPPORTED_YET.

@DaveGosselin-MariaDB DaveGosselin-MariaDB self-assigned this Oct 29, 2025
@DaveGosselin-MariaDB DaveGosselin-MariaDB force-pushed the 12.3-MDEV-37932-full-outer-join-syntax branch 2 times, most recently from 2270908 to 2c8d18f Compare October 29, 2025 18:14
@DaveGosselin-MariaDB DaveGosselin-MariaDB force-pushed the 12.3-MDEV-37932-full-outer-join-syntax branch from 2c8d18f to 556ba5b Compare October 29, 2025 19:35
@spetrunia
Copy link
Member

spetrunia commented Oct 31, 2025

I wonder if we need to set JOIN_TYPE_OUTER.
Before this patch it is used in a very odd way:

$ grep -rn JOIN_TYPE_OUTER sql
sql/sql_select.cc:31713:    /* JOIN_TYPE_OUTER is just a marker unrelated to real join */
sql/sql_derived.cc:803:        cursor->outer_join|= JOIN_TYPE_OUTER;
sql/table.h:2217:#define JOIN_TYPE_OUTER 4U     /* Marker that this is an outer join */

It is set only in sql_derived.cc: mysql_derived_prepare().
as far as I understand, the logic is: if we have a derived table dt that's LEFT JOIN'ed:

 ... LEFT JOIN  (SELECT .... FROM t1, t2  ) dt ON expr ```

then we set JOIN_TYPE_OUTER for all the tables in the derived table (t1, t2 in this example).

But then if a table has JOIN_TYPE_OUTER it does not mean that it will be joined with its peers using any outer join operation - here t1 and t2 are joined with inner join...

@spetrunia
Copy link
Member

... and that's all the input.
Need to figure if we need to set JOIN_TYPE_OUTER here (I think, no) and then this patch is good.

@DaveGosselin-MariaDB
Copy link
Member Author

... and that's all the input. Need to figure if we need to set JOIN_TYPE_OUTER here (I think, no) and then this patch is good.

It's logically sufficient to specify on JOIN_TYPE_FULL in combination with the LEFT/RIGHT bits as that will be unambiguous in the code. We don't strictly need to mark JOIN_TYPE_OUTER because FULL OUTER JOIN and FULL JOIN are equivalent. However, I wasn't sure if we wanted to keep the marking so as to preserve the user input when rendering back the query during EXPLAIN EXTENDED (or any other place where the query is shown, like during VIEW .frm file creation).

Syntax support for FULL JOIN, FULL OUTER JOIN, NATURAL FULL JOIN, and
NATURAL FULL OUTER JOIN in the parser.

While we accept full join syntax, such joins are not yet supported.
Queries specifying any of the above joins will fail with
ER_NOT_SUPPORTED_YET.
@DaveGosselin-MariaDB DaveGosselin-MariaDB force-pushed the 12.3-MDEV-37932-full-outer-join-syntax branch from 556ba5b to 1fa730f Compare November 3, 2025 17:12
@DaveGosselin-MariaDB DaveGosselin-MariaDB changed the base branch from main to 12.2-mdev-36813-full-outer-join November 5, 2025 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants